<script setup>
import { ref, watch } from 'vue'

const emits = defineEmits(['closeDialog', 'dialogConfirm', 'clickClose'])
const visible = ref(false)
const props = defineProps({
    showDialog: Boolean,
    dialogType: String,
    dialogTitle: {
        type: String,
        default: '提示'
    }
})

watch(() => props.showDialog, newVal => visible.value = newVal)

const close = () => props.dialogType === 'add' ? emits('closeDialog') : emits('clickClose')
const dialogConfirm = () => emits('dialogConfirm')
const dialogClose = () => emits('clickClose')
</script>

<template>
    <div class="dialog">
        <t-dialog
            @close="close"
            @confirm="dialogConfirm"
            @cancel="dialogClose"
            @closeBtnClick="dialogClose"
            closeOnEscKeydown
            closeOnOverlayClick
            footer
            :header="dialogTitle"
            v-model:visible="visible">
            <slot></slot>
        </t-dialog>
    </div>
</template>

<style scoped lang="scss">
</style>
